package models

// RegisterModel 注册页面model
type RegisterModel struct {
	UserName    string
	Password    string
	PhoneNumber string
}

// Register 注册
func Register(r RegisterModel) error {
	c, err := SelectByPhoneNumber(r.PhoneNumber)
	if err != nil {
		return err
	}
	if c.ContactId != 0 {
		AddUser(Users{UserName: r.UserName, Password: r.Password, ContactId: c.ContactId})
		return nil
	} else {
		return err
	}
}
